Skip to content

gh-114198: Rename dataclass __replace__ argument to 'self'#114251

Merged
ericvsmith merged 1 commit into
python:mainfrom
pschanely:fix-issue-114198
Jan 18, 2024
Merged

gh-114198: Rename dataclass __replace__ argument to 'self'#114251
ericvsmith merged 1 commit into
python:mainfrom
pschanely:fix-issue-114198

Conversation

@pschanely

@pschanely pschanely commented Jan 18, 2024

Copy link
Copy Markdown
Contributor

This change renames the dataclass __replace__ method's first argument name from obj to self.

This results in a more tidy set of signatures for dataclasses; i.e.:

>>> import dataclasses, inspect, pprint
>>> @dataclasses.dataclass
... class Foo:
...   x: int
... 
>>> pprint.pprint({n:inspect.signature(f) for n, f in inspect.getmembers(Foo, inspect.isfunction)})
{'__eq__': <Signature (self, other)>,
 '__init__': <Signature (self, x: int) -> None>,
 '__replace__': <Signature (self, /, **changes)>,
 '__repr__': <Signature (self)>}

This change renames the dataclass __replace__ method's first argument
name from 'obj' to 'self'.
@pschanely pschanely requested a review from ericvsmith as a code owner January 18, 2024 15:30
@ghost

ghost commented Jan 18, 2024

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.
CLA signed

@ericvsmith ericvsmith left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@ericvsmith ericvsmith merged commit 339fc3c into python:main Jan 18, 2024
kulikjak pushed a commit to kulikjak/cpython that referenced this pull request Jan 22, 2024
…hongh-114251)

This change renames the dataclass __replace__ method's first argument
name from 'obj' to 'self'.
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
…hongh-114251)

This change renames the dataclass __replace__ method's first argument
name from 'obj' to 'self'.
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
…hongh-114251)

This change renames the dataclass __replace__ method's first argument
name from 'obj' to 'self'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants